import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams,ViewController } from 'ionic-angular';
import {NewsDetailPage} from '../news-detail/news-detail';
import {HousesService} from '../../providers/houses.service';
/**
 * Generated class for the NewsPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-news',
  templateUrl: 'news.html',
  providers:[HousesService]
})
export class NewsPage {
  housenews:any;
  hoSer:any;
  news:any;
  getNews:any;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public viewCtrl: ViewController,
    private house:HousesService,
) {
  }

  ionViewDidLoad() {

    // this.house.getNews().then( data => {
    //     console.log();
    //   this.getNews = data;
    //   });
    let that = this;
    that.house.getNews(function (result) {
      console.log(result);
      that.getNews = result;
    });

  }



  back(){
    this.viewCtrl.dismiss();

    //
  }

  toNewDetail(getNew){
    this.navCtrl.push(NewsDetailPage,{"news":getNew});
  }
}
